//
//  SASingletonTemplate.h
//  Shikamaru
//
//  Created by FangGeek on 2017/3/31.
//  Copyright © 2017年 FangGeek. All rights reserved.
//
//头文件声明
#define SASINGLETON_FOR_HEADER(name) + (instancetype)shared##name;

//.m文件声明
#define SASINGLETON_FOR_CLASS(name) \
\
static id _instance; \
\
+ (id)allocWithZone:(struct _NSZone *)zone \
{ \
static dispatch_once_t onceToken; \
dispatch_once(&onceToken, ^{ \
_instance = [super allocWithZone:zone]; \
}); \
return _instance; \
} \
\
+ (instancetype)shared##name \
{ \
static dispatch_once_t onceToken; \
dispatch_once(&onceToken, ^{ \
_instance = [[self alloc] init]; \
});\
return _instance; \
} \
\
+ (id)copyWithZone:(struct _NSZone *)zone \
{ \
return _instance; \
}
